package com.jokins.common.actions.action;

import com.jokins.common.actions.exception.BusinessException;

/**
 * 〈〉<br>
 * 执行业务过程
 * @author Mr.Wang
 * @create 2024/9/9
 */
public abstract class BaseAction<T extends BaseActionContext> implements Action<T> {

    @Override
    public final void execute(final T actionContext) throws BusinessException {
        init(actionContext);
        preprocess(actionContext);
        validate(actionContext);
        process(actionContext);
        postprocess(actionContext);
    }

    protected void init(final T actionContext) throws BusinessException {
    }

    protected void preprocess(final T actionContext) throws BusinessException {

    }

    protected void validate(final T actionContext) throws BusinessException {

    }

    protected abstract void process(T actionContext) throws BusinessException;

    protected void postprocess(final T actionContext) throws BusinessException {

    }
}